<template>
  <div>
    <div class="login_container">
      <div class="login_header">UNI-ADMIN</div>
      <div class="login_footer">
        <div class="login_footer_one">
          <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="用户名">
              <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="密码">
              <el-input v-model="form.pass"></el-input>
            </el-form-item>

            <el-form-item>
              <el-button type="primary" @click="onSubmit">登录</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      form: {
        name: "",
        pass: "",
      },
    };
  },
methods: {
    onSubmit(){
        this.$axios.post("https://www.liulongbin.top:8888/api/private/v1/login",{
            username:this.form.name,
            password:this.form.pass
        }).then((res)=>{
            console.log(res);
            if(res.data.meta.status=="200"){
                localStorage.setItem("token",res.data.data.token)
                alert('登录成功')
                this.$router.push('/homepage')
            }else{
                alert("登录失败")
            }
        })
    }
},
};
</script>
<style lang="scss">
.login_container {
  width: 600px;
  height: 300px;
  margin: 100px auto;
  border: 1px solid gainsboro;
  .login_header {
    width: 100%;
    height: 50px;
    font-size: 30px;
    font-weight: bold;
    color: gray;
    text-align: center;
    line-height: 50px;
    box-sizing: border-box;
    border-bottom: 1px solid gainsboro;
  }
  .login_footer {
    width: 100%;
    height: 250px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    .login_footer_one {
      width: 86%;
      height: 100%;
    }
  }
}
</style>